package com.keshe.dao;

import com.keshe.domain.RoomIn;
import com.keshe.util.DBUtil;

import java.util.List;

public class RoomInDao {
    //插入入住信息
    public int insert(RoomIn ri){
        String sql="insert roomIn(username,idcard,roomId,datain,dataout,dataNum,coastY) values (?,?,?,?,?,?,?)";
        int count= DBUtil.update(sql,ri.getUsername(),ri.getIdcard(),ri.getRoomId(),ri.getDatain(),ri.getDataout(),ri.getDataNum(),ri.getCoastY());
        return count;
    }
    //修改入住天数
    public int uptateDateNum(int dataNum,String idcard){
        String sql="uptate roomIn set dataNum=? where username=?";
        int count=DBUtil.update(sql,dataNum,idcard);
        return count;
    }

    //修改退房日期（退房）
    public int updateDateout(String dateout,String idcard)
    {
        String sql="update roomIn set dataout=? where idcard=?";
        int count=DBUtil.update(sql,dateout,idcard);
        return count;
    }
    //删除入住信息
    public int delete(String idcard){
        String sql="delete from roomIn where idcard=?";
        int count=DBUtil.update(sql,idcard);
        return count;
    }
    //查看入住名单
    public List<RoomIn> select(){
        String sql="select * from roomIn";
        List<RoomIn> ri =DBUtil.query(sql,RoomIn.class);
        return ri;
    }
    //根据姓名查询入住名单信息
    public List<RoomIn> selectUserName(String username){
        String sql="select * from roomIn where username=?";
        List<RoomIn> ri =DBUtil.query(sql,RoomIn.class,username);
        return ri;
    }
}
